#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          axis2c
# Required-Start:    $local_fs $network
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start Axis2/C application server
### END INIT INFO

case "$1" in
  start)
    LOGFILE=/var/log/axis2c.log
    touch $LOGFILE
    chown daemon $LOGFILE
    export AXIS2C_HOME=/opt/wso2/wsf_cpp
    cd $AXIS2C_HOME/bin
    sudo -Enu daemon sh -c "./axis2_http_server -p 8080>$LOGFILE 2>&1 &"
    ;;

  stop)
    killall -INT axis2_http_server
    ;;

  restart|force-reload)
    $0 stop
    $0 start
    ;;

  *)
    echo "Usage: $0 {start|stop|restart|force-reload}" >&2
    exit 1
    ;;
esac
